package com.solution.admin.order.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.solution.admin.order.dao.OrderContractDao;
import com.solution.admin.order.entity.OrderContractEntity;
import com.solution.common.dao.impl.BaseDaoImpl;
import com.solution.common.page.PageBean;
import com.solution.common.page.PageParam;

/**
 * 订单合同DAO实现
 * @author lilp
 * @date 2017-09-18 19:23:07
 */
@Repository
public class OrderContractDaoImpl extends BaseDaoImpl<OrderContractEntity> implements OrderContractDao {

	/**
	 * 保存订单合同信息
	 * @param orderContractEntity
	 * @return
	 * @author lilp
	 * @date 2017-09-18 19:23:07
	 */
	@Override
	public long saveOrderContract(OrderContractEntity orderContractEntity) {
		return super.insert(orderContractEntity);
	}

	/**
	 * 分页查询订单合同信息
	 * @param pageParam 分页对象
	 * @param orderContract 分页参数
	 * @return PageBean 分页参数及数据
	 * @author lilp
	 * @date 2017-09-18 19:23:07
	 */
	public PageBean listOrderContractPage(PageParam pageParam, Map<String, Object> param) {
		return super.listPage(pageParam, param);
	}

	/**
	 * 更新订单合同
	 * @param orderContractEntity
	 * @return
	 * @author lilp
	 * @date 2017-09-18 19:23:07
	 */
	@Override
	public int updateOrderContract(OrderContractEntity orderContractEntity) {
		return super.update(orderContractEntity);
	}

	/**
	 * 删除订单合同
	 * @param orderContractId
	 * @return
	 * @author lilp
	 * @date 2017-09-18 19:23:07
	 */
	public int deleteOrderContractById( Long id) {
		return super.deleteById(id);
	}
	
	/**
	 * 根据条件查询订单合同
	 * @param param
	 * @return
	 * @author lilp
	 * @date 2017-09-18 19:23:07
	 */
	@Override
	public List<OrderContractEntity> listOrderContract( Map<String, Object> param) {
		return super.listBy(param);
	}
	
	/**
	 * 修改订单合同（合同文档列表的确认）状态
	 * @param param
	 * @return
	 */
	public int updateOrderContractStatus(Map<String, Object> param){
		return getSessionTemplate().update(getStatement("updateOrderContractStatus"),param);
	}
	
	/**
	 * 重新上传合同，修改合同附件
	 * @param contract
	 * @return
	 * @author lilp
	 */
	public int reuploadContract(OrderContractEntity contract){
		return getSessionTemplate().update(getStatement("reuploadContract"),contract);
	}
}
